package com.codez.unionpay.springboot.quartz;

import org.quartz.CronScheduleBuilder;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.codez.job.MyJob;

/**
 * 
 * @author 干净的代码
 * @创建时间  ： 2019-06-15
 * 
 */

@Configuration
public class JobConfig {

	@Bean
	public JobDetail jobDetail() {
		return JobBuilder.newJob(MyJob.class).withIdentity("myjob", "mygroup").storeDurably().build();
	}
	
	 @Bean
	    public Trigger myTrigger(){
	        Trigger trigger = TriggerBuilder.newTrigger()
	                .forJob(jobDetail())
	                .withIdentity("myTrigger1","myTriggerGroup1")
	                .startNow()
	                .withSchedule(CronScheduleBuilder.cronSchedule("0/5 * * * * ?"))
	                .build();
	        return trigger;
	    }
	
	
}
